<?php
include 'include/header.php';
?>
<div class="panel panel-default">
  <div class="panel-heading">Edit Profil Akun</div>
  <div class="panel-body">

		<div class="panel panel-default">
					<div class="panel-body">
						<div class="col-lg-4">
						<?php
						foreach($data_user as $data)
						{
						?>
							
									<form action="<?php echo base_url().'index.php/akun/edit_profil/true/'.$this->session->userdata('id_user'); ?>" class="form-horizontal" method="post" data-parsley-validate>
											<div class="form-group">
												<label class="control-label col-lg-4">Email</label>
												<div class="col-lg-8">
													<input type="email" class="form-control" name="email" id="email" data-parsley-trigger="change" required value="<?php echo $data['email']?>">
												</div>
											</div>
											<div class="form-group">
												<label class="control-label col-lg-4">Password</label>
												<div class="col-lg-8">
													<input type="password" class="form-control" name="pass" id="pass" data-parsley-trigger="change">
												</div>
											</div>
											<div class="form-group">
												<label class="control-label col-lg-4">Ulangi Password</label>
												<div class="col-lg-8">
													<input type="password" class="form-control" name="pass2" id="pass2" data-parsley-trigger="change" onkeyup="checkPass(); return false;">
													<span id="confirmMessage" class="confirmMessage"></span>
												</div>
											</div>
											<div class="form-group" >
												<label class="control-label col-lg-4"></label>
												<div class="col-lg-8">
													<button type="submit" class="btn btn-primary" onclick="post(event)">Simpan</button>
												</div>
											</div>
									</form>
							<?php
							}
							?>
							
						</div>
					</div>
			</div>
		
	</div>
</div>


<?php
include 'include/footer.php';
?>
<script>
var base_url = "<?php echo base_url();?>"
	function checkPass()
    {
        var pass1 = document.getElementById('pass');
        var pass2 = document.getElementById('pass2');   
        var message = document.getElementById('confirmMessage');
        var goodColor = "#66cc66";
        var badColor = "#ff6666";
        if(pass.value == pass2.value){
            pass2.style.backgroundColor = goodColor;
            message.style.color = goodColor;
            message.innerHTML = "Passwords Cocok!";
        }else{
            pass2.style.backgroundColor = badColor;
            message.style.color = badColor;
            message.innerHTML = "Passwords Tidak Cocok!";
        }
    }  
	
	function post(e)
	{
		if($('#pass').val() != $('#pass2').val())
		{
			alert('Password tidak cocok!');
				e.preventDefault();
				return false;
		} else
			{
				
			}
	}

</script>